package im.elephas.androfan.activity;

import im.elephas.androfan.R;
import im.elephas.androfan.common.widget.FavoriteWidget;
import im.elephas.androfan.common.widget.PageWidget;
import im.elephas.androfan.fanfouapi.items.StatusItem;
import android.graphics.Color;
import android.hardware.SensorEvent;
import android.widget.LinearLayout;

public class FavoritesActivity extends StatusActivity {

	private int page = 1;

	@Override
	protected void getStatuses() {
		getFanfouApi().getFavorite(count, getPage(), mIStatusesEvent,
				getApiCaller().mIErrorEvent);
	}

	@Override
	protected void getMoreStatuses() {
	}

	@Override
	public void onSensorChanged(SensorEvent event) {
	}

	@Override
	protected void setTitle() {
		setTitle(getFanfouApi().getUser().getScreenName() + " 查看收藏");
	}

	@Override
	protected void refreshStatuses() {
		isGettingStatuses = false;

		setContentView(R.layout.statuses);

		linearLayout = (LinearLayout) findViewById(R.id.statusesLinearLayout);

		setLineWidget();
		
		for (StatusItem item : listStatusItems) {
			FavoriteWidget fw = new FavoriteWidget(linearLayout, getActivity(),
					item);
			fw.addToParentView();
			
			setLineWidget();
		}

		PageWidget pw = new PageWidget(linearLayout, getActivity(),
				new PageWidget.PageOpration() {

					@Override
					public void doPage(int page) {
						setPage(page);
						getStatuses();
					}
				}, getPage());
		pw.addToParentView();
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getPage() {
		return page;
	}
}
